#include<bits/stdc++.h>
using namespace std;
int t;
int n[25],m[25],l[25],v[25];
int d[10005],u[10005],a[10005];
int p[10005];
int s,c;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    for(int i=1;i<=t;i++){
        cin>>n[i]>>m[i]>>l[i]>>v[i];
        for(int j=1;j<=n[i];j++){
            cin>>d[j]>>u[j]>>a[j];
        }
        for(int j=1;j<=m[i];j++){
            cin>>p[j];
        }
    }
    cout<<s<<" "<<c<<endl;
    return 0;
}